#include <stdio.h>

int main()
{
	int x, n, p, memoire1, memoire2, resultat;
	printf("Valeur de x = "); scanf("%d", &x);
	printf("Nombre de bits a inverser n = "); scanf("%d", &n);
	printf("A partir de la position p = "); scanf("%d", &p);
	
	resultat = x >> (p-1);
	memoire1 = resultat << (p-1);
	memoire1 = x - memoire1;
	resultat = ~resultat;
	memoire2 = resultat >> n;
	memoire2 = memoire2 << n;
	memoire2 = resultat - memoire2;
	memoire2 = memoire2 << (p-1);
	resultat = memoire1 + memoire2;
	
	printf("Apres inversion la nouvelle est %d.\n", resultat);
	
	return 0;
}